package cn.enited.devtools.apiaggregator.api.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;

@Accessors(chain = true)
public class ApiAnalysisObject implements Serializable {
    private static final long serialVersionUID = 2516546218598458869L;

    @Getter
    @Setter
    private String name;

    @Getter
    @Setter
    private String projectName;

    @Getter
    private final List<RemoteService> freeService;

    @Getter
    private final LinkedList<RemoteService> dependService;

    @Getter
    private final Set<String> serviceIds;

    public ApiAnalysisObject() {
        this.freeService = new ArrayList<>();
        this.dependService = new LinkedList<>();
        this.serviceIds = new HashSet<>();
    }

    public void addFreeService(RemoteService srv) {
        this.freeService.add(srv);
        this.serviceIds.add(srv.getId());
    }

    public void addDependService(RemoteService srv) {
        this.dependService.add(srv);
        this.serviceIds.add(srv.getId());
    }

    public void addDependService(int index, RemoteService srv) {
        this.dependService.add(index, srv);
        this.serviceIds.add(srv.getId());
    }
}
